package com.blb.mapper;

import com.blb.entity.Shipping;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;
/**/
/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ZhengSaiNan
 * @since 2019-11-16
 */
public interface ShippingMapper extends BaseMapper<Shipping> {
    /**
     * 查询所有订单信息
     * @return
     */
    public List<Map<String,Object>> getAllShipMessage(String companyId);

    /**
     * 查询所有订单信息总条数
     * @return
     */
    public int countShipMessage(String companyId);

    /**
     * 查询所有物流
     * @return
     */
    @Select("SELECT logistics_id ,logistics_name FROM t_logistics where company_id=#{companyId}")
    public List<Map<String,Object>> getAllLogistics(String companyId);

    /**
     * 查询物流车类型
     * @return
     */
    @Select("SELECT vehicle_type FROM t_vehicle WHERE logistics_id=#{logisticsId} and status='无任务' GROUP BY vehicle_type ")
    public List<String> getAllVehicleType(String logisticsId);

    /**
     * 查询司机信息
     * @param logisticsId
     * @param vehicle_type
     * @return
     */
    public List<Map<String ,Object>> getAllDriverMessage(@Param("logisticsId") String logisticsId, @Param("vehicle_type") String vehicle_type);

    /**
     * 更改订单状态、物流信息
     * @param shipping
     */
    @Select("UPDATE t_order SET order_status='3',shipping_date=#{shippingDate},shipping_method_id=#{shippingMethodId} WHERE order_id=#{orderNum}")
    public void updateOrder(Shipping shipping);

    /**
     * 查询物品详细信息
     * @param orderNum
     * @return
     */
    public Map<String ,Object> getDetailMessage(String orderNum);

    /**
     * 更改车辆状态
     * @param vehicleId
     */
    @Select("UPDATE t_vehicle SET `status`='有任务' WHERE vehicle_id=#{vehicleId}")
    public void updateVehicle(String vehicleId);
    /**
     * 更改司机状态
     * @param driverId
     */
    @Select("UPDATE t_driver SET `status`='有任务' WHERE driver_id=#{driverId}")
    public void updateDriver(String driverId);
}
